<?php
// +----------------------------------------------------------------------
// | ScrollPHP
// +----------------------------------------------------------------------
// | @copyright Copyright (c) 2014 PhpStorm All rights reserved.
// +----------------------------------------------------------------------
// | @license Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author LIZHEN
// +----------------------------------------------------------------------
// | @version 0.0.1 (2014-09-04)
// +----------------------------------------------------------------------
// | @info $Id: ConnectionManager.class.php 2766 14-9-5 上午9:57 LIZHEN $
// +----------------------------------------------------------------------
// | @package

class ConnectionManager extends Base
{
    private static $_instance = null;

    public static function getConnection()
    {
        if (self::$_instance == null) {
            //按照配置文件寻找驱动类，然后连接DB
            switch (C('db=>driver')) {
                case 'pdo' :
                    self::$_instance = new PdoDriver();
                    break;
                case 'mysql' :
                    self::$_instance = new MySqlDriver();
                    break;
                default :
                    self::$_instance = new PdoDriver();
                    break;
            }
        }
        return self::$_instance;
    }

    /**
     * 断开连接
     */
    public static function closeConnection()
    {
        if (null !== self::$_instance) {
            self::$_instance . close();
        }
    }
}